package com.pan.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pan.domain.Apply;
import com.pan.domain.User;
import com.pan.domain.Zhanshi;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;


@Mapper
public interface UserDao extends BaseMapper<User> {
    //展示界面信息
    //delete = 0 的人不展示
    @Select("select `id`,`name`,`sex`,`age`,`address`,`email`,`danme`,`position`,`salary`,`loc` from tbl_user,tbl_deptno where tbl_user.deptno=tbl_deptno.deptno and `delete` = 1")
    List<Zhanshi> getSome();

    //靠用户名查询tbl_user表全部信息
    @Select("select * from tbl_user where `username` = #{username}")
    User getByUsername(String username);

    //根据部门查询所拥有的权限
    @Select("select `aty` from tbl_deptno where `deptno` = #{deptno}")
    String getByDeptno(Integer deptno);

    //查询用户自己的请求信息
    @Select("select `name`,`deptno`,`position`,`applyTime`,`delete` from tbl_apply where `name` = #{name}")
    Apply getOwn(User user);

    //发送修改申请
    @Insert("insert into tbl_apply (`name`,`deptno`,`position`) values (#{name},#{deptno},#{position})")
    Boolean applyOrChange(User user);

    //根据姓名查询用户信息
    @Select("select * from tbl_user where `name` = #{name}")
    User getByName(String name);
}